// pages/food/food.js

Page({

  /**
   * 页面的初始数据
   */
  data: {
    array: [

      {
        id: 0,
        name: "九田牛果木炭火烤肉",
        desc: "解放路128号奥斯卡购物中心西座2楼",
        imgUrl: "https://img.meituan.net/msmerchant/72155c654d7f4c1d8182dfc9a7701c8b172908.jpg@600w_600h_1l",
        extras: "世界地质公园-平邑县",
      },
      {
        id: 1,
        name: "蛋糕先生",
        desc: "通达路与前十街交汇西200米路北",
        imgUrl: "https://img.meituan.net/msmerchant/ea61b6b3b44d740d8d9fb03327d3866b29544.jpg@380w_214h_1e_1c",
        extras: "世界地质公园-蒙阴县",
      },
      {
        id: 2,
        name: "过锅瘾三汁焖锅",
        desc: "通达路与前十街交汇东方不夜城3楼保利国际影城东侧",
        imgUrl: "https://img.meituan.net/msmerchant/0ec5a9bbb3ab626708ec10bdbec17a78162231.jpg@600w_600h_1l",
        extras: "",
      },
      {
        id: 3,
        name: "清真全羊老店",
        desc: "开阳路38号",
        imgUrl: "https://p0.meituan.net/bbia/4952f3f58fd369a4e0b5369b7efa4d9192253.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 4,
        name: "鲁南炒鸡王",
        desc: "新华一路与开阳路交汇处往东30米路南",
        imgUrl: "https://p1.meituan.net/deal/479f3e8cb04f995684a4a528172aeb4d324082.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 5,
        name: "三人行酱汁鸡",
        desc: "新华路与银雀山路交汇南200米路西",
        imgUrl: "https://p0.meituan.net/bbia/20e27d48da275aa918549494d0988dfd131050.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 6,
        name: "莫沫南路茶货铺",
        desc: "红旗路茂业百货奥斯卡美食街西23号",
        imgUrl: "https://p0.meituan.net/bbia/f6709b62c1b8454dcc18bcd5429e6a0d115994.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 7,
        name: "水磨坊永和",
        desc: "银雀山路与新华路交汇南50米路东",
        imgUrl: "https://p1.meituan.net/deal/7787d470fd5141d1f3b979493760c35f347378.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 8,
        name: "藤井家精致料理",
        desc: "金一路与中丘路交汇上城国际A座三楼",
        imgUrl: "https://p0.meituan.net/deal/9dcd4b8607423b9fadbc47a677d188f6364169.jpg@600w_600h_1l",
        extras: "备注",
      },
      {
        id: 9,
        name: "大唐食府",
        desc: "湖东二路与教育巷交汇",
        imgUrl: "https://p1.meituan.net/deal/191b01f5cd633a2c118efcd1156f8113466946.jpg@600w_600h_1l",
        extras: "备注",
      },
      {
        id: 10,
        name: "上岛咖啡欧蕾餐厅",
        desc: "八一路与银雀山路交汇南100米路西",
        imgUrl: "https://p0.meituan.net/deal/__47144775__8359016.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 11,
        name: "沂河桥主题餐厅",
        desc: "北京路与秀水路交汇西150米路北",
        imgUrl: "https://img.meituan.net/msmerchant/abad03f736d83de85b8b81c4ea90d123866485.jpg@600w_600h_1l",
        extras: "备注",
      },
      {
        id: 12,
        name: "妈妈的味道",
        desc: "育才路170号",
        imgUrl: "https://img.meituan.net/msmerchant/ac003064e7ae5c651c4ac90d9282c9e1158449.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 13,
        name: "轻食主义",
        desc: "银雀山路与八一路交汇处北150米路东隆盛糕点南侧",
        imgUrl: "https://img.meituan.net/msmerchant/c493a276974b3a8e55909366c822eb4d154266.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 14,
        name: "小柒香辣蟹",
        desc: "前十街与临西四路交汇南200米路东",
        imgUrl: "https://img.meituan.net/msmerchant/949c0eeadcdea223fc2c8cc8167b614d107692.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 14,
        name: "嗨声部落主题餐厅",
        desc: "费县建设路东方城四楼",
        imgUrl: "https://p1.meituan.net/mogu/fe0efd90e7c96c06f0ccbdee4d9fc32b97997.jpg@380w_214h_1e_1c",
        extras: "备注",
      },
      {
        id: 14,
        name: "天山明珠",
        desc: "通达路与解放路交汇泰盛广场四楼4055号",
        imgUrl: "https://img.meituan.net/msmerchant/bdf405011e6b25f3d406ffbc14299aa0204355.jpg@600w_600h_1l",
        extras: "备注",
      },


    ],
  },

  // 点击item的时候执行
  onItemClick: function (e) {
    console.log(e);

    let that = this;
    let index = e.currentTarget.dataset.index;
    console.log('index = ' + index);

    var imgArr = [];
    for (let i = 0; i < this.data.array.length; i++) {
      imgArr[i] = this.data.array[i].imgUrl;
    }

    wx.previewImage({
      current: that.data.array[index].imgUrl,
      urls: imgArr,
      success: function (res) {
        console.log(res)
      }
    })
  },

  // 下拉刷新
  onPullDownRefresh: function () {
    var n1 = setTimeout(function () {
      wx.showToast({
        success: "loading",
        title: '数据已更新',
      });
      clearTimeout(n1);
    }, 3000);
  },

  // 到达底部
  onReachBottom: function () {
    wx.showToast({
      title: '我是有底线的',
    })
  },

})